package com.cloud.wms.ui.inside.transfer;

import android.content.Intent;
import android.os.Message;

import com.cloud.core.multistate.NavIconType;
import com.cloud.widget.ScanText;
import com.cloud.wms.R;
import com.cloud.wms.app.FineExApplication;
import com.cloud.wms.base.BaseBarActivity;
import com.cloud.wms.config.SpKey;
import com.cloud.wms.tools.BarAdapter;
import com.cloud.wms.ui.inside.contract.TransferDownContact;
import com.cloud.wms.ui.inside.presenter.TransferDownPresenter;
import com.dylanc.loadinghelper.ViewType;

import butterknife.BindView;

/**
 * Created by FC on 2021/5/17.
 * Desc：移库上下架扫描库位
 */
public class TransferDownStartActivity extends BaseBarActivity<TransferDownPresenter> implements TransferDownContact.View {
    @BindView(R.id.scan_text)
    ScanText scanText;

    @Override
    protected String barTitle() {
        return "移库下架";
    }

//    protected void initToolBar() {
//        loadingHelper.register(ViewType.TITLE, new BarAdapter(barTitle(), NavIconType.BACK, false, "下架设置", v -> {
//            startActivity(new Intent(this, TransferSettingActivity.class));
//        }));
//        loadingHelper.setDecorHeader(ViewType.TITLE);
//    }

    @Override
    protected int getResId() {
        return R.layout.activity_transfer_down_start;
    }

    @Override
    protected void initEvent() {
        initScanText(scanText);
        FineExApplication.component().kv().encode(SpKey.TRANSFER_SCAN_CONTAINER, true);
    }

    @Override
    protected void onScanHandle(String result, int resultCode) {
        super.onScanHandle(result, resultCode);
        scanText.addHistory(result);
        mPresenter.checkPos(result);
    }

    @Override
    public void onSuccess(Message message) {
        if (message.what == TransferDownPresenter.CHECK_POS) {
            Integer posID = (Integer) message.obj;
            TransferDownGoodsActivity.jumpToNext(this, String.valueOf(posID));
        }
    }

    @Override
    protected void setupComponent() {
        getActivityComponent().inject(this);
    }
}
